package com.ruoyi.storehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.storehouse.domain.StockStorehouse;
import com.ruoyi.storehouse.service.IStockStorehouseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库房管理Controller
 * 
 * @author yx
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/storehouse/storehouse")
public class StockStorehouseController extends BaseController
{
    @Autowired
    private IStockStorehouseService stockStorehouseService;

    /**
     * 查询库房管理列表
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockStorehouse stockStorehouse)
    {
        startPage();
        List<StockStorehouse> list = stockStorehouseService.selectStockStorehouseList(stockStorehouse);
        return getDataTable(list);
    }

    /**
     * 导出库房管理列表
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:export')")
    @Log(title = "库房管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockStorehouse stockStorehouse)
    {
        List<StockStorehouse> list = stockStorehouseService.selectStockStorehouseList(stockStorehouse);
        ExcelUtil<StockStorehouse> util = new ExcelUtil<StockStorehouse>(StockStorehouse.class);
        util.exportExcel(response, list, "库房管理数据");
    }

    /**
     * 获取库房管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:query')")
    @GetMapping(value = "/{storehouseId}")
    public AjaxResult getInfo(@PathVariable("storehouseId") Integer storehouseId)
    {
        return success(stockStorehouseService.selectStockStorehouseByStorehouseId(storehouseId));
    }

    /**
     * 新增库房管理
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:add')")
    @Log(title = "库房管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockStorehouse stockStorehouse)
    {
        return toAjax(stockStorehouseService.insertStockStorehouse(stockStorehouse));
    }

    /**
     * 修改库房管理
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:edit')")
    @Log(title = "库房管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockStorehouse stockStorehouse)
    {
        return toAjax(stockStorehouseService.updateStockStorehouse(stockStorehouse));
    }

    /**
     * 删除库房管理
     */
    @PreAuthorize("@ss.hasPermi('storehouse:storehouse:remove')")
    @Log(title = "库房管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{storehouseIds}")
    public AjaxResult remove(@PathVariable Integer[] storehouseIds)
    {
        return toAjax(stockStorehouseService.deleteStockStorehouseByStorehouseIds(storehouseIds));
    }
}
